package com.hgkj.cloud.base.transactional;

import org.springframework.core.annotation.AliasFor;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.lang.annotation.*;

/**
 * @Author: yangcg   用于回滚 write
 */
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@Transactional(
        value = "transactionManager",
        isolation = Isolation.DEFAULT,
        propagation = Propagation.REQUIRED,
        rollbackFor = {Exception.class}
)
public @interface DBWriteTransactional {
    @AliasFor(
            annotation = Transactional.class
    )
    String transactionManager() default "transactionManager";

    @AliasFor(
            annotation = Transactional.class,
            attribute = "rollbackFor"
    )
    Class<? extends Throwable>[] rollbackFor() default {Exception.class};

    @AliasFor(
            annotation = Transactional.class
    )
    Class<? extends Throwable>[] noRollbackFor() default {};
}
